/**
 * Foxit Software Inc.
 * Copyright(C) 2005-2014, all rights reserved.
 * The following code is copyrighted and contains proprietary information
 * and trade secrets of Foxit Software Inc.

 * Description: PopupMousePtHandler
 * Author: shaojie zhuo
 * Update: shaojie zhuo (2014-05-29 14:03)
 */
define(function (require, exports, module) {
    /**
     * @param baseAnnotPlugin
     * @constructor
     * @extends WebPDF.Event.IReaderMousePtHandler
     */
    var PopupMousePtHandler = function (markupAnnotHandler, annotHandlerManager) {
        this._markupAnnotHandler = markupAnnotHandler;
        this._annotHandlerManager = annotHandlerManager;
        this._bMoveDown = false;
        this._oldPosY = 0;
        this._oldPosX = 0;
    };
    PopupMousePtHandler.prototype = {
        getType : function(){
            return "Popup Annot Mouse Pt Handler";
        },
        onLButtonDown: function(event){
            var popupElem = this._markupAnnotHandler.getDirectPopupParent(event.target);
            if(!popupElem){
                return false;
            }
            WebPDF.Common.preventDefaults(event);
            this._markupAnnotHandler.setFocusAnnotByTarget(popupElem);
            this._bMoveDown = true;
            this._oldPosY = event.pageY; //当前鼠标位置
            this._oldPosX = event.pageX; //当前鼠标位置
            return true;
        },
        onLButtonUp: function(event){
            this._bMoveDown = false;
            this._annotHandlerManager.onDraw();
            return false;
        },
        onLButtonDblClk: function(event){
            return false;
        },
        onMouseMove: function(event){
            if (this._bMoveDown) {
                this._annotHandlerManager.clearCanvas(); //暂时使用clearCanvas，在移动的时候不显示popup和annot的连线
                this._markupAnnotHandler.moveCurrentPopupAnnot(event.pageX - this._oldPosX, event.pageY - this._oldPosY);
                this._oldPosY = event.pageY; //当前鼠标位置
                this._oldPosX = event.pageX; //当前鼠标位置
                return true;
            }
            return false;
        },
        onRButtonDown: function(event){
            return false;
        },
        onRButtonUp: function(event){
            return false;
        },
        onRButtonDblClk: function(event){
            return false;
        },
        onMouseWheel: function(event){
            return false;
        },
        onMouseOver: function(event){
           return false;
        },
        onMouseOut: function(event){
            return false;
        },
        onMouseLeave: function(event){
            return false;
        },
        onMouseEnter: function(event){
            return false;
        }
    };
    WebPDF.Event.PopupMousePtHandler = PopupMousePtHandler;
    return WebPDF.Event.PopupMousePtHandler;
});